package com.rainng.coursesystem.controller;

import com.rainng.coursesystem.dao.mapper.AdminMapper;
import com.rainng.coursesystem.dao.mapper.StudentMapper;
import com.rainng.coursesystem.dao.mapper.TeacherMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/home")
public class HomeController extends BaseController {
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private TeacherMapper teacherMapper;
    @Autowired
    private AdminMapper adminMapper;
    @PutMapping("/edit/{id}/{type}/{password}")
    public String get(@PathVariable Integer id, @PathVariable Integer type,@PathVariable String password) {
        System.out.println(id+" "+type+" "+password);
        if(type==1){
            studentMapper.updatePasswordById(password,id);
        } else if (type == 2) {
            teacherMapper.updatePasswordById(password,id);
        } else if (type == 3) {
            adminMapper.updatePasswordById(password,id);
        }
        return "修改成功！";
    }

}
